package com.tzkyzj.tiremanagersystem.eneities;

import java.io.Serializable;

public class Tire implements Serializable {
    private Long id;
    private String tireNumber;
    private String vehiclePlateNumber;
    private String trailerPlateNumber;
    private String tireModel;
    private String tireBrand;
    private String installDate;
    private String scrapDate;
    private Integer installMileage;
    private Integer currentMileage;
    private String transportCompany;
    private Integer axleNumber;
    private String tirePosition;
    private String position;
    private String status;

    // 新增字段
    private String currentPlateNumber;
    private Integer scrapMileage;
    private Integer usedDays;
    private Double tirePrice;
    private Double installCost;
    private Double repairCost;
    private Double swapCost;
    private String repairRecords;
    private String swapRecords;

    // 构造方法
    public Tire() {}

    // Getter和Setter方法
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }

    public String getTireNumber() { return tireNumber; }
    public void setTireNumber(String tireNumber) { this.tireNumber = tireNumber; }

    public String getVehiclePlateNumber() { return vehiclePlateNumber; }
    public void setVehiclePlateNumber(String vehiclePlateNumber) { this.vehiclePlateNumber = vehiclePlateNumber; }

    public String getTrailerPlateNumber() { return trailerPlateNumber; }
    public void setTrailerPlateNumber(String trailerPlateNumber) { this.trailerPlateNumber = trailerPlateNumber; }

    public String getTireModel() { return tireModel; }
    public void setTireModel(String tireModel) { this.tireModel = tireModel; }

    public String getTireBrand() { return tireBrand; }
    public void setTireBrand(String tireBrand) { this.tireBrand = tireBrand; }

    public String getInstallDate() { return installDate; }
    public void setInstallDate(String installDate) { this.installDate = installDate; }

    public String getScrapDate() { return scrapDate; }
    public void setScrapDate(String scrapDate) { this.scrapDate = scrapDate; }

    public Integer getInstallMileage() { return installMileage; }
    public void setInstallMileage(Integer installMileage) { this.installMileage = installMileage; }

    public Integer getCurrentMileage() { return currentMileage; }
    public void setCurrentMileage(Integer currentMileage) { this.currentMileage = currentMileage; }

    public String getTransportCompany() { return transportCompany; }
    public void setTransportCompany(String transportCompany) { this.transportCompany = transportCompany; }

    public Integer getAxleNumber() { return axleNumber; }
    public void setAxleNumber(Integer axleNumber) { this.axleNumber = axleNumber; }

    public String getTirePosition() { return tirePosition; }
    public void setTirePosition(String tirePosition) { this.tirePosition = tirePosition; }

    public String getPosition() { return position; }
    public void setPosition(String position) { this.position = position; }

    public String getStatus() { return status; }
    public void setStatus(String status) { this.status = status; }

    // 新增字段的Getter和Setter
    public String getCurrentPlateNumber() { return currentPlateNumber; }
    public void setCurrentPlateNumber(String currentPlateNumber) { this.currentPlateNumber = currentPlateNumber; }

    public Integer getScrapMileage() { return scrapMileage; }
    public void setScrapMileage(Integer scrapMileage) { this.scrapMileage = scrapMileage; }

    public Integer getUsedDays() { return usedDays; }
    public void setUsedDays(Integer usedDays) { this.usedDays = usedDays; }

    public Double getTirePrice() { return tirePrice; }
    public void setTirePrice(Double tirePrice) { this.tirePrice = tirePrice; }

    public Double getInstallCost() { return installCost; }
    public void setInstallCost(Double installCost) { this.installCost = installCost; }

    public Double getRepairCost() { return repairCost; }
    public void setRepairCost(Double repairCost) { this.repairCost = repairCost; }

    public Double getSwapCost() { return swapCost; }
    public void setSwapCost(Double swapCost) { this.swapCost = swapCost; }

    public String getRepairRecords() { return repairRecords; }
    public void setRepairRecords(String repairRecords) { this.repairRecords = repairRecords; }

    public String getSwapRecords() { return swapRecords; }
    public void setSwapRecords(String swapRecords) { this.swapRecords = swapRecords; }

    // 获取显示的车牌号
    public String getDisplayPlateNumber() {
        if (currentPlateNumber != null && !currentPlateNumber.isEmpty()) {
            return currentPlateNumber;
        } else if (vehiclePlateNumber != null && trailerPlateNumber != null) {
            return vehiclePlateNumber + "/" + trailerPlateNumber;
        } else if (vehiclePlateNumber != null) {
            return vehiclePlateNumber;
        } else if (trailerPlateNumber != null) {
            return trailerPlateNumber;
        } else {
            return "未安装";
        }
    }

    // 获取完整位置描述
    public String getFullPosition() {
        if (axleNumber != null && tirePosition != null) {
            return axleNumber + "轴 " + tirePosition;
        } else if (axleNumber != null) {
            return axleNumber + "轴";
        } else if (tirePosition != null) {
            return tirePosition;
        }
        return position != null ? position : "--";
    }

    // 计算使用公里数
    public Integer getUsedMileage() {
        if (scrapMileage != null && installMileage != null) {
            return scrapMileage - installMileage;
        } else if (currentMileage != null && installMileage != null) {
            return currentMileage - installMileage;
        }
        return null;
    }

    @Override
    public String toString() {
        return "Tire{" +
                "id=" + id +
                ", tireNumber='" + tireNumber + '\'' +
                ", vehiclePlateNumber='" + vehiclePlateNumber + '\'' +
                ", trailerPlateNumber='" + trailerPlateNumber + '\'' +
                ", currentPlateNumber='" + currentPlateNumber + '\'' +
                ", tireModel='" + tireModel + '\'' +
                ", tireBrand='" + tireBrand + '\'' +
                ", installDate='" + installDate + '\'' +
                ", scrapDate='" + scrapDate + '\'' +
                ", installMileage=" + installMileage +
                ", currentMileage=" + currentMileage +
                ", scrapMileage=" + scrapMileage +
                ", transportCompany='" + transportCompany + '\'' +
                ", axleNumber=" + axleNumber +
                ", tirePosition='" + tirePosition + '\'' +
                ", position='" + position + '\'' +
                ", status='" + status + '\'' +
                ", usedDays=" + usedDays +
                ", tirePrice=" + tirePrice +
                ", installCost=" + installCost +
                ", repairCost=" + repairCost +
                ", swapCost=" + swapCost +
                ", repairRecords='" + repairRecords + '\'' +
                ", swapRecords='" + swapRecords + '\'' +
                '}';
    }
}